home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 June: Reference Library / Dev.CD Jun 99 RL Disk 1.toast / What's New / Development Kits / Mac_OS_USB_DDK_v1.2 / Interfaces / UniversalHIDModule.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-15  |  4.4 KB  |  150 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        UniversalHIDModule.h
  3.  
  4.      Contains:    This describes the interface a higher level part of the OS uses
  5.  
  6.      Version:    xxx put version here xxx
  7.  
  8. */
  9.  
  10. /* We are not USB specific, but we share many definitions with the USB spec*/
  11. #ifndef __UNIVERSALHIDMODULE__
  12. #define __UNIVERSALHIDMODULE__
  13.  
  14. #ifndef __MACTYPES__
  15. #include <MacTypes.h>
  16. #endif
  17. #ifndef __USB__
  18. #include <USB.h>
  19. #endif
  20.  
  21.  
  22.  
  23. #if PRAGMA_ONCE
  24. #pragma once
  25. #endif
  26.  
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30.  
  31. #if PRAGMA_IMPORT
  32. #pragma import on
  33. #endif
  34.  
  35. #if PRAGMA_STRUCT_ALIGN
  36.     #pragma options align=mac68k
  37. #elif PRAGMA_STRUCT_PACKPUSH
  38.     #pragma pack(push, 2)
  39. #elif PRAGMA_STRUCT_PACK
  40.     #pragma pack(2)
  41. #endif
  42.  
  43. typedef UInt32                             UHIDModuleConnectionID;
  44. /* FunctionPtr to be called when inturrupt occurs*/
  45. typedef CALLBACK_API_C( void , UHIDInterruptProcPtr )(void *theData, UInt32 refcon);
  46. /* FunctionPtr definitions for UniversalHIDModule dispatch table*/
  47. typedef CALLBACK_API_C( OSStatus , UHIDGetDeviceInfoProcPtr )(UInt32 inInfoSelector, void *outInfo);
  48. typedef CALLBACK_API_C( OSStatus , UHIDGetHIDDescriptorProcPtr )(UInt32 inDescriptorType, UInt32 inDescriptorIndex, UInt32 *ioBufferSize, void *outBuffer);
  49. typedef CALLBACK_API_C( OSStatus , UHIDClaimDeviceProcPtr )(UHIDModuleConnectionID *outConnectionID, UInt32 reserved);
  50. typedef CALLBACK_API_C( OSStatus , UHIDReleaseDeviceProcPtr )(UHIDModuleConnectionID inConnectionID);
  51. typedef CALLBACK_API_C( OSStatus , UHIDInstallInterruptProcPtr )(UHIDModuleConnectionID inConnectionID, UHIDInterruptProcPtr inInterruptProc, UInt32 inRefcon);
  52. typedef CALLBACK_API_C( OSStatus , UHIDControlDeviceProcPtr )(UHIDModuleConnectionID inConnectionID, UInt32 inControlSelector, void *ioControlData);
  53.  
  54. enum {
  55.     kCurrentDispatchTableVersion = 5,
  56.     kOldestCompatableDispatchTableVersion = 5
  57. };
  58.  
  59. /*
  60.    UHIDModuleDispatchTable is exported by the HIDModule's PEF container
  61.    dispatchTableCurrentVersion is kCurrentDispatchTableVersion
  62.    dispatchTableOldestVersion is kOldestCompatableDispatchTableVersion
  63.           (the oldest built client using this API that this UHIDModule will work with)
  64.    vendorID is who wrote this UniversalHIDModule (hi word of 0 and USB vendorID is valid)
  65. */
  66.  
  67. struct UHIDModuleDispatchTableStruct {
  68.     UInt16                             dispatchTableCurrentVersion;
  69.     UInt16                             dispatchTableOldestVersion;
  70.     UInt32                             vendorID;
  71.     UInt32                             vendorSpecific;
  72.     UInt32                             reserved;
  73.     UHIDGetDeviceInfoProcPtr         pUHIDGetDeviceInfo;
  74.     UHIDClaimDeviceProcPtr             pUHIDClaimDevice;
  75.     UHIDReleaseDeviceProcPtr         pUHIDReleaseDevice;
  76.     UHIDInstallInterruptProcPtr     pUHIDInstallInterrupt;
  77.     UHIDControlDeviceProcPtr         pUHIDControlDevice;
  78.     UHIDGetHIDDescriptorProcPtr     pUHIDGetHIDDescriptor;
  79. };
  80. typedef struct UHIDModuleDispatchTableStruct UHIDModuleDispatchTableStruct;
  81.  
  82. typedef UHIDModuleDispatchTableStruct     UHIDModuleDispatchTable;
  83. typedef UHIDModuleDispatchTableStruct *    UHIDModuleDispatchTablePtr;
  84. /* the prototypes for the actual functions in the UHIDModule follow*/
  85. EXTERN_API_C( OSStatus )
  86. UHIDGetDeviceInfo                (UInt32                 inInfoSelector,
  87.                                  void *                    outInfo);
  88.  
  89. EXTERN_API_C( OSStatus )
  90. UHIDGetHIDDescriptor            (UInt32                 inDescriptorType,
  91.                                  UInt32                 inDescriptorIndex,
  92.                                  UInt32 *                ioBufferSize,
  93.                                  void *                    outBuffer);
  94.  
  95. /* Claim and release are a way to insure that only one client is connected*/
  96. EXTERN_API_C( OSStatus )
  97. UHIDClaimDevice                    (UHIDModuleConnectionID * outConnectionID,
  98.                                  UInt32                 reserved);
  99.  
  100. EXTERN_API_C( OSStatus )
  101. UHIDReleaseDevice                (UHIDModuleConnectionID  inConnectionID);
  102.  
  103. EXTERN_API_C( OSStatus )
  104. UHIDInstallInterrupt            (UHIDModuleConnectionID  inConnectionID,
  105.                                  UHIDInterruptProcPtr     inInterruptProc,
  106.                                  UInt32                 inRefcon);
  107.  
  108. EXTERN_API_C( OSStatus )
  109. UHIDControlDevice                (UHIDModuleConnectionID  inConnectionID,
  110.                                  UInt32                 inControlSelector,
  111.                                  void *                    ioControlData);
  112.  
  113. /* these are the constants to be passed to UHIDControlDevice*/
  114.  
  115. enum {
  116.     kUHIDRemoveInterruptHandle    = 0,
  117.     kUHIDVendorSpecificControlStart = 0x00010000
  118. };
  119.  
  120. /* these are the constants to be passed to UHIDGetDeviceInfo*/
  121.  
  122. enum {
  123.     kUHIDGetVendorID            = 0,
  124.     kUHIDGetProductID            = 1,
  125.     kUHIDGetMaxPacketSize        = 2,
  126.     kUHIDVendorSpecificGetInfoStart = 0x00010000
  127. };
  128.  
  129.  
  130. #if PRAGMA_STRUCT_ALIGN
  131.     #pragma options align=reset
  132. #elif PRAGMA_STRUCT_PACKPUSH
  133.     #pragma pack(pop)
  134. #elif PRAGMA_STRUCT_PACK
  135.     #pragma pack()
  136. #endif
  137.  
  138. #ifdef PRAGMA_IMPORT_OFF
  139. #pragma import off
  140. #elif PRAGMA_IMPORT
  141. #pragma import reset
  142. #endif
  143.  
  144. #ifdef __cplusplus
  145. }
  146. #endif
  147.  
  148. #endif /* __UNIVERSALHIDMODULE__ */
  149.  
  150.